package org.dey.controller;

import org.dey.pojo.Dietary;
import org.dey.pojo.PageVo;
import org.dey.service.DietaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class DietaryController {
    @Autowired
    DietaryService dietaryService;

    @PostMapping("dietary.action/{pageNum}/{pageSize}" )
    public PageVo<Dietary> queryDietar(@RequestBody Dietary dietary,
                                       @PathVariable int pageNum,
                                       @PathVariable int pageSize) {

        PageVo<Dietary> queryuser = dietaryService.queryDietar(dietary, pageNum, pageSize);
        return queryuser;
    }

    //添加
    @PostMapping("addDietary.action")
    public int insertDietar(@RequestBody Dietary dietary) {

        int insertuser = dietaryService.insertDietar(dietary);

        return insertuser;
    }

    @DeleteMapping("delDietary.action/{id}")
    public int deleteDietar(@PathVariable int id) {
        return dietaryService.deleteDietar(id);
    }

    @GetMapping("qureyDietaryById.action/{id}")
    public Dietary queryDietarByid(@PathVariable int id) {
        return dietaryService.queryDietarByid(id);
    }

    @PutMapping("updateDietary.action")
    public int updateDietar(@RequestBody Dietary dietary) {
        return dietaryService.updateDietar(dietary);
    }
}
